***********************************************************************************************
************					Fig G6 - WTP per Hour Fig by Various Cuts *****
************					
************************************************************************************************/
use .\data\clean\I10W_laneuse_dataset_15nov14_wcensus, clear
drop if holiday==1
drop if dow==0 | dow==6
keep if acct_type=="PRIVATE"
drop TTdiff_ELSpeed
g TTdiff_ELSpeed= (dist/MLspeed)-(dist/ELspeed)
sort acct_no
keep if inlist(hour,5,6,7,8) /*period=="AM Peak"*/
gen WTP=charged_toll/(TTdiff_ELSpeed)
gen temp1=WTP<0
gen Price_per_mile=charged_toll/dist
g miles=cond(dist<2,"0-2", ///
	cond(dist<5, "2-5", ///
	cond(dist<7, "5-7", "7-10.5")))
keep if WTP>0&WTP~=.	
replace TTdiff_ELSpeed=TTdiff_ELSpeed*60
*create frequency
sort acct_no
g count=1
egen freqpermo=sum(count), by(acct_no month)
sort acct_no entry_time
egen appearance=seq(), by(acct_no)


count if TTdiff_ELSpeed>1.5 & appearance==1
count if TTdiff_ELSpeed>1.5 & appearance>1 & appearance<6
count if TTdiff_ELSpeed>1.5 & appearance>29 & appearance<251
count if TTdiff_ELSpeed>1.5 & appearance>99
*** PANEL B
twoway (lpoly WTP TTdiff_ELSpeed if TTdiff_ELSpeed>1.5 & appearance==1,bwidth(.05) lc(black)), ///
		 ytitle("Willingness-to-Pay per Hour" "(in dollars)") ///
		 xtitle("{&Delta}Travel Time (in minutes)") xlabel(0(10)30)  ylabel(0(20)120) /// 
	   legend(off) plotregion(style(none)) name(WTP_1, replace) ysc(r(0 125)) scale(1.5)

twoway (lpoly WTP TTdiff_ELSpeed if TTdiff_ELSpeed>1.5 & appearance>1 & appearance<6,bwidth(.05) lc(black)), ///
		 ytitle("Willingness-to-Pay per Hour" "(in dollars)") ///
		 xtitle("{&Delta}Travel Time (in minutes)") xlabel(0(10)30)  ylabel(0(20)120)  /// 
	   legend(off) plotregion(style(none)) name(WTP_2_5, replace)  ysc(r(0 125)) scale(1.5)
twoway (lpoly WTP TTdiff_ELSpeed if TTdiff_ELSpeed>1.5 & appearance>29 & appearance<51,bwidth(.05) lc(black)), ///
		 ytitle("Willingness-to-Pay per Hour" "(in dollars)") ///
		 xtitle("{&Delta}Travel Time (in minutes)") xlabel(0(10)30)  ylabel(0(20)120)  /// 
	   legend(off) plotregion(style(none)) name(WTP_30_50, replace)  ysc(r(0 125)) scale(1.5)
twoway (lpoly WTP TTdiff_ELSpeed if TTdiff_ELSpeed>1.5 & appearance>99 ,bwidth(.05) lc(black)), ///
		 ytitle("Willingness-to-Pay per Hour" "(in dollars)") ///
		 xtitle("{&Delta}Travel Time (in minutes)") xlabel(0(10)30)  ylabel(0(20)120)  /// 
	   legend(off) plotregion(style(none)) name(WTP_100, replace)  ysc(r(0 125)) scale(1.5)
graph combine WTP_3 WTP_4_10 WTP_11_15 WTP_16_20, col(2)
graph export .\results\appendix\figs\AF6pb.png, replace
putexcel set ".\results\appendix\AppendixFigsTabs.xlsx", sheet("Appendix Figure C.6") modify
  putexcel A1 = picture(".\results\appendix\figs\AF6pa.png")
  putexcel AW1 = picture(".\results\appendix\figs\AF6pb.png")
